import request from "./request";

function http(url, method, data) {
  return request({
    url: url || "/",
    method: method || "GET",
    data:
      method === "POST" || method === "PUT" || method === "DELETE" ? data : {},
    params: method === "GET" ? data : {},
  })
    .then((res) => {
      return Promise.resolve(res);
    })
    .catch((err) => {
      return Promise.reject(err);
    });
}

export default http;
